/**
 * 
 */
package com.monte.test.export;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.UUID;

import org.junit.Test;

/**
 * @author fengmengyue
 *
 */
public class DataInit {
	
	@Test
	public void initData() throws SQLException{
		Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@10.1.3.54:1521:ora9i", "ndmp_ps", "ndmp_ps");
		String insert = "INSERT INTO DEMO_DATA_TEST(ID,NAME,AGE,SEX,DESCRIPTION) VALUES(?,?,?,?,?)";
		PreparedStatement pstmt = conn.prepareStatement(insert);
		for(int i = 0; i < 1000000; i++){
			pstmt.setString(1, UUID.randomUUID().toString());
			pstmt.setString(2, "张三"+i);
			pstmt.setInt(3, i);
			pstmt.setString(4, "男");
			pstmt.setString(5, "我是备注我怕谁");
			pstmt.addBatch();
			if(i != 0 && (i % 1000==0)){
				System.out.println(i);
				pstmt.executeBatch();
				pstmt.clearBatch();
			}
		}
		pstmt.executeBatch();
		pstmt.close();
		conn.close();
	}
}
